<template>
  <div>
    <el-form ref="businessFrom" :model="temp" :rules="rules" label-position="top">
      <el-row :gutter="10">
        <el-col :span="8">
          <el-form-item label="前端访问路径" prop="frontUrl">
            <el-input v-model.trim="temp.frontUrl"/>
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="支付记录过期时间 (秒)" prop="paymentLogTimeout" label-width="190px">
            <el-input v-model.trim.number="temp.paymentLogTimeout" type="number"/>
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="平台收款人账户" prop="receiverExAcctNo">
            <el-input v-model.trim="temp.receiverExAcctNo"/>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row :gutter="10">
        <el-col :span="8">
          <el-form-item label="最大提醒金额" prop="singleMaxWithdrawAmount">
            <el-input v-model.trim="temp.singleMaxWithdrawAmount"/>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label=" 新网收款方平台客户编号(自己平台)" prop="xwBankPayeePlatformCustomerNo">
            <el-input v-model.trim="temp.xwBankPayeePlatformCustomerNo"/>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="新网收款方账户号(新网平台)" prop="xwBankPayeeAcctNo">
            <el-input v-model.trim="temp.xwBankPayeeAcctNo"/>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row :gutter="10">
        <!--<el-col :span="8">
          <el-form-item label="翔天openId(新网)" prop="xiangtianOpenId">
            <el-input v-model.trim="temp.xiangtianOpenId"/>
          </el-form-item>
        </el-col>-->
        <el-col :span="8">
          <el-form-item label="开放网关过期时间(秒)" prop="paramTokenTimeout">
            <el-input v-model.trim="temp.paramTokenTimeout" type="number"/>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="后端网关入口访问路径" prop="frontGatewayUrl">
            <el-input v-model.trim="temp.backendGatewayUrl" type="number"/>
          </el-form-item>
        </el-col>
      </el-row>

    </el-form>
  </div>
</template>

<script>
import { codeValidation } from '@/methods/codeValidation'

export default {
  name: 'Business',
  props: {
    businessData: {
      type: Object,
      default: function() {
        return {}
      }
    }
  },

  data() {
    return {
      temp: {
        frontUrl: '',
        paymentLogTimeout: '',
        receiverExAcctNo: '',
        xwBankPayeePlatformCustomerNo: '',
        xwBankPayeeAcctNo: '',
        singleMaxWithdrawAmount: '',
        // xiangtianOpenId: '',
        paramTokenTimeout: '',
        backendGatewayUrl: ''
      },
      rules: {
        frontUrl: [
          { required: true, message: '请输入', trigger: 'blur' }
        ],
        paymentLogTimeout: [
          { required: true, message: '请输入', trigger: 'blur' }
        ],
        receiverExAcctNo: [
          { required: true, message: '请输入', trigger: 'blur' }
        ],
        singleMaxWithdrawAmount: [
          { required: true, message: '请输入', trigger: 'blur' }
        ]
      }
    }
  },
  watch: {
    businessData() {
      this.copyTemp()
    }
  },
  created() {
    this.copyTemp()
  },
  methods: {

    // 初始化数据
    copyTemp() {
      for (var key in this.temp) {
        this.temp[key] = this.businessData[key]
      }
    },

    // 表单验证
    verifyData() {
      var v = false
      this.$refs['businessFrom'].validate((valid) => {
        v = valid
      })
      return v
    },

    // 验证通过后 调用此方法 返回数据
    returnData() {
      return this.temp
    }

  }
}
</script>

<style scoped>

</style>
